/*
@STI LICENSE
(C) 2006-2008 Universit�t Innsbruck.

This file is part of myOntology.

myOntologyis free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

myOntologyis distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with myOntology.  If not, see <http://www.gnu.org/licenses/>.

@STI LICENSE */
/**
 * 
 */
package org.myontology.specialpages;

import org.myontology.controller.AbstractAction;
import org.myontology.controller.AbstractController;
import org.myontology.controller.AttributeHolder;
import org.myontology.controller.AttributeLevel;
import org.myontology.controller.ValueHandler;

/**
 * @author <a href="michael.hackl@sti2.at">Michael Hackl</a>
 * Project: Myontology - www.myontology.org
 * STI
 *
 */
public class SpecialPageAction extends AbstractAction {

	private SpecialPageRegistry registry;
	private AbstractController controller;
	
	public static final ValueHandler<String> PAGE_LABEL = new ValueHandler<String>(AttributeLevel.SESSION,SpecialPageAction.class);
	public static final ValueHandler<SpecialPageHolder> PAGE = new ValueHandler<SpecialPageHolder>(AttributeLevel.SESSION,SpecialPageAction.class);
	

	/* (non-Javadoc)
	 * @see org.myontology.controller.Action#execute(org.myontology.controller.AttributeHolder)
	 */

	public void execute(AttributeHolder attributes) {
		String pageKey = attributes.getRequestParameter("pageKey"); 
		PAGE_LABEL.setValue(attributes, registry.retrieveLabelForKey(pageKey));
		SpecialPageHolder p = registry.retrieveSpecialPage(pageKey);
		controller.injectDepencies(p.getConfig(), attributes);
		p.init();
		PAGE.setValue(attributes, p);

	}

}
